package com.neu;

/**
 * @author ：geekvan
 * @date ：2020/11/8 14:08
 */
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Flights {
    static final String JDBC_DRIVER = "com.omnisci.jdbc.OmniSciDriver";
    static final String DB_URL = "jdbc:omnisci:219.216.65.81:6274:omnisci";
    static final String USER = "admin";
    static final String PASS = "HyperInteractive";
    public static void main(String[] args) throws SQLException {
        Connection conn = null;
        Statement stmt = null;
        try {
            Class.forName(JDBC_DRIVER);

            conn = DriverManager.getConnection(DB_URL, USER, PASS);

            stmt = conn.createStatement();
            String sql = "CREATE TABLE IF NOT EXISTS venue (id TEXT, row_s TEXT, type_s TEXT);";
//            stmt.executeUpdate(sql);
//            sql = "INSERT INTO venue VALUES ('123412','hello' , 'X');";
//            stmt.executeUpdate(sql);
//            sql = "INSERT INTO venue VALUES ('543112','row' ,  'J');";
//            stmt.executeUpdate(sql);

            //drop table
//            sql="DROP TABLE venue;";
//            stmt.executeUpdate((sql));

            //copy to csv
//            sql="COPY venue FROM 'venue.csv';";
//            stmt.executeUpdate(sql);

            sql = "SELECT row_s,id from venue limit 1";
            ResultSet rs = stmt.executeQuery(sql);
            while (rs.next()) {
                String uniquecarrier = rs.getString("id");
                System.out.println("id: " + uniquecarrier);
            }

            rs.close();
            stmt.close();
            conn.close();
        } catch (SQLException se) {
            //Handle errors for JDBC
            se.printStackTrace();
            System.out.println("SQL Exception!");
        } catch (Exception e) {
            e.printStackTrace();
            if (stmt != null)
                stmt.close();
            if (conn != null)
                conn.close();
            System.out.println("Other Exception!");
        }
    }
}
